package Jw20241002;

import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 链表拆分
 * User: 王圆豪
 * Date: 2024-10-02
 * Time: 20:41
 */
public class Test1 {
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> l = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            l.add(sc.nextInt());
        }
        int standard = sc.nextInt();
        LinkedList<Integer> minL = new LinkedList<>();
        LinkedList<Integer> maxL = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            int cur = l.get(i);
            if (cur > standard){
                maxL.add(cur);
            }else {
                minL.add(cur);
            }
        }
        System.out.println(minL.size());
        if (!minL.isEmpty()) {
            System.out.print(minL.get(0));
            for (int i = 1; i < minL.size(); i++) {
                System.out.print(" " + minL.get(i));
            }
        }
        System.out.println();
        System.out.println(maxL.size());
        if (!maxL.isEmpty()) {
            System.out.print(maxL.get(0));
            for (int i = 1; i < maxL.size(); i++) {
                System.out.print(" " + maxL.get(i));
            }
        }
    }
}
